#!/usr/bin/env bats

@test "filter no-around color no-case: 2 words" {
  cd $BATS_TEST_DIRNAME
  expected="file11:6:[01;31m[KPresent[m[K is [0;32mdejected[0m here;"
  result="$(fish -c 'tbgs Present dejected')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs present dejected')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs present dejEcTeD')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs no-case Present dejected')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs no-case present dejected')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs no-case present dejEcTeD')"; [ "$result" = "$expected" ]
  expected=""
  result="$(fish -c 'tbgs case present dejEcTeD')"; [ "$result" = "$expected" ]
}

@test "filter no-around color no-case: 4 words" {
  cd $BATS_TEST_DIRNAME
  expected="file11:4:[01;31m[KMerry[m[K [0;32mdays[0m [0;33mwill[0m [0;34mcome[0m, believe."
  result="$(fish -c 'tbgs Merry days will come')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs no-case Merry days will come')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs merry dAyS wIlL cOMe')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs no-case merry dAyS wIlL cOMe')"; [ "$result" = "$expected" ]
  expected="file11:4:[0;34mMerry[0m [01;31m[Kdays[m[K [0;32mwill[0m [0;33mcome[0m, believe."
  result="$(fish -c 'tbgs days will come Merry')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs no-case days will come Merry')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs dAyS wIlL cOMe merry')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs no-case dAyS wIlL cOMe merry')"; [ "$result" = "$expected" ]
}

@test "filter no-around color no-case: 2 words partial match" {
  cd $BATS_TEST_DIRNAME
  expected="file11:6:[01;31m[KPres[m[Kent is [0;32mdejec[0mted here;"
  result="$(fish -c 'tbgs Pres dejec')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs pres dejec')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs pres dejEc')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs no-case Pres dejec')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs no-case pres dejec')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs no-case pres dejEc')"; [ "$result" = "$expected" ]
  expected=""
  result="$(fish -c 'tbgs case present dejEc')"; [ "$result" = "$expected" ]
}

@test "filter no-around color no-case: 2 words word only appears in file path" {
  cd $BATS_TEST_DIRNAME
  expected=""
  result="$(fish -c 'tbgs Present file')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs file dejected')"; [ "$result" = "$expected" ]
  result="$(fish -c 'tbgs the file')"; [ "$result" = "$expected" ]
}
